package com.itheima.web.controller;

import com.itheima.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @RequestMapping("/param2")
    public String param2 (
            @RequestParam("username") String user,
            String password ,
            String nickname ,
            Integer age,
            String  hobby
    ) {
        System.out.println(user);
        System.out.println(password);
        System.out.println(nickname);
        System.out.println(age);
        System.out.println(hobby);
        return "/success.jsp";
    }

    @RequestMapping("param3")
    public String param2 (User user) {
        System.out.println(user);
        return "/success.jsp";
    }

    @RequestMapping("param4")
    public String param4 (User user) {
        System.out.println(user);
        return "/success.jsp";
    }

    @RequestMapping("/param5")
    public String param5(@RequestHeader("User-Agent") String userAgent, @CookieValue("JSESSIONID") String sessionId){
        System.out.println(userAgent);
        System.out.println(sessionId);

        return "success.jsp";
    }

}
